<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<c:set var="uri" value="${pageContext.request.contextPath}" />
    
    <script type="text/javascript">
    var uri='${uri}';
        </script>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <title>修改-学生</title>
        <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/layui/css/layui.css">
            
            <style type="text/css">
            
            .loadingModel {
                position: absolute;
                top: 0;
                left: 0;
                display: none;
                background-color: rgba(9, 9, 9, 0.63);
                width: 100%;
                height: 100%;
                z-index: 1000;
            }
            .loading-content {
                width: 50%;
                text-align: center;
                background: #ffffff;
                border-radius: 6px;
                line-height: 30px;
                z-index: 10001;
            }
            </style>
            </head>
            <div id="loadingDiv"></div>
            <div id="imgModal"></div>
            <div class="layui-container" style="overflow:hidden;height:2000px">
            <div class="layui-row">
            <div class="layui-col-lg12">
            <fieldset class="layui-elem-field">
            <legend>修改-学生</legend>
            <div class="layui-field-box">
            <div >
            
            
            <div class="layui-form-item layui-form-text" id="stuNoParentContent">
            <label class="layui-form-label">学号</label>
            <div class="layui-input-block">
            <input type="text"  style="width:500px;display:inline" value="${data.stuNo}" placeholder="请输入学号" id="stuNo" class="layui-input">	<span style="color:red">*必填</span>
                
                </div>
                </div>
                
                <div class="layui-form-item layui-form-text" id="passWordParentContent">
                <label class="layui-form-label">登录密码</label>
                <div class="layui-input-block">
                <input type="text"  style="width:500px;display:inline" value="${data.passWord}" placeholder="请输入登录密码" id="passWord" class="layui-input">	<span style="color:red">*必填</span>
                    
                    </div>
                    </div>
                    
                    <div class="layui-form-item layui-form-text" id="realNameParentContent">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-block">
                    <input type="text"  style="width:500px;display:inline" value="${data.realName}" placeholder="请输入姓名" id="realName" class="layui-input">	<span style="color:red">*必填</span>
                        
                        </div>
                        </div>
                        
                        <div class="layui-form-item layui-form-text" id="sexParentContent">
                        <label class="layui-form-label">性别</label>
                        <div class="layui-input-block">
                        <select  id="sex" style="height:30px;width:500px;display:inline" >
                        <c:forEach items="${sexList}" var="item">
                            <c:if test="${item.id==data.sex}">
                                <option value="${item.id}" selected>${item.name}</option>
                                    </c:if>
                                    <c:if test="${item.id!=data.sex}">
                                        <option value="${item.id}">${item.name}</option>
                                            </c:if>
                                            </c:forEach>
                                            </select>
                                            
                                            </div>
                                            </div>
                                            
                                            <div class="layui-form-item layui-form-text" id="celPhoneParentContent">
                                            <label class="layui-form-label">联系电话</label>
                                            <div class="layui-input-block">
                                            <input type="text"  style="width:500px;display:inline" value="${data.celPhone}" placeholder="请输入联系电话" id="celPhone" class="layui-input">	<span style="color:red">*必填</span>
                                                
                                                </div>
                                                </div>
                                                
                                                <div class="layui-form-item layui-form-text" id="majorIdParentContent">
                                                <label class="layui-form-label">所属专业</label>
                                                <div class="layui-input-block">
                                                <select  id="majorId" style="height:30px;width:500px;display:inline" >
                                                <c:forEach items="${majorInfoList}" var="item">
                                                    <c:if test="${item.id==data.majorId}">
                                                        <option value="${item.id}" selected>${item.name}</option>
                                                            </c:if>
                                                            <c:if test="${item.id!=data.majorId}">
                                                                <option value="${item.id}">${item.name}</option>
                                                                    </c:if>
                                                                    </c:forEach>
                                                                    </select>
                                                                    <span style="color:red">*必填</span>
                                                                    
                                                                    </div>
                                                                    </div>
                                                                    
                                                                    <div class="layui-form-item layui-form-text" id="classIdParentContent">
                                                                    <label class="layui-form-label">班级</label>
                                                                    <div class="layui-input-block">
                                                                    <select  id="classId" style="height:30px;width:500px;display:inline" >
                                                                    <c:forEach items="${classInfoList}" var="item">
                                                                        <c:if test="${item.id==data.classId}">
                                                                            <option value="${item.id}" selected>${item.name}</option>
                                                                                </c:if>
                                                                                <c:if test="${item.id!=data.classId}">
                                                                                    <option value="${item.id}">${item.name}</option>
                                                                                        </c:if>
                                                                                        </c:forEach>
                                                                                        </select>
                                                                                        
                                                                                        </div>
                                                                                        </div>
                                                                                        
                                                                                        <div class="layui-form-item layui-form-text" id="directIdParentContent">
                                                                                        <label class="layui-form-label">方向</label>
                                                                                        <div class="layui-input-block">
                                                                                        <select  id="directId" style="height:30px;width:500px;display:inline" >
                                                                                        <c:forEach items="${majorDirectInfoList}" var="item">
                                                                                            <c:if test="${item.id==data.directId}">
                                                                                                <option value="${item.id}" selected>${item.name}</option>
                                                                                                    </c:if>
                                                                                                    <c:if test="${item.id!=data.directId}">
                                                                                                        <option value="${item.id}">${item.name}</option>
                                                                                                            </c:if>
                                                                                                            </c:forEach>
                                                                                                            </select>
                                                                                                            
                                                                                                            </div>
                                                                                                            </div>
                                                                                                            
                                                                                                            <div class="layui-form-item layui-form-text" id="enterYearParentContent">
                                                                                                            <label class="layui-form-label">入学年份</label>
                                                                                                            <div class="layui-input-block">
                                                                                                            <input type="text"  style="width:500px;display:inline" value="${data.enterYear}" placeholder="请输入入学年份（请输入数字）" id="enterYear" class="layui-input">	<span style="color:red">*必填</span>
                                                                                                                
                                                                                                                </div>
                                                                                                                </div>
                                                                                                                
                                                                                                                <div class="layui-form-item">
                                                                                                                <div class="layui-input-block">
                                                                                                                <button class="layui-btn" onclick="submitData();" >立即提交</button>
                                                                                                                <button  class="layui-btn layui-btn-primary"  onclick="javascript:history.back(-1);" >返回</button>
                                                                                                                </div>
                                                                                                                </div>
                                                                                                                </div>
                                                                                                                </div>
                                                                                                                </fieldset>
                                                                                                                </div>
                                                                                                                </div>
                                                                                                                </div>
                                                                                                                <script type="text/javascript" src="${pageContext.request.contextPath}/static/common/jquery-1.11.1.min.js"></script>
                                                                                                                    
                                                                                                                    
                                                                                                                    
                                                                                                                    
                                                                                                                    
                                                                                                                    <script type="text/javascript" src="${pageContext.request.contextPath}/static/layui/layui/layui.js"></script>
                                                                                                                        <script type="text/javascript" src="${pageContext.request.contextPath}/static/common/utils/listutils.js?v=6884"></script>
                                                                                                                            
                                                                                                                            <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/common/selectSearch/jquery.searchableSelect.css?d=129339" />
                                                                                                                                <script type="text/javascript" src="${pageContext.request.contextPath}/static/common/selectSearch/jquery.searchableSelect.js?d=1293393"></script>
                                                                                                                                    
                                                                                                                                    
                                                                                                                                    <script type="text/javascript">
                                                                                                                                    
                                                                                                                                    
                                                                                                                                    
                                                                                                                                    $(function(){
                                                                                                                                        
                                                                                                                                        $('#majorId').next().remove();
                                                                                                                                        $('#majorId').searchableSelect();
                                                                                                                                        $("#majorId").change(function(){
                                                                                                                                            changeMajorIdVal();
                                                                                                                                        });
                                                                                                                                        changeMajorIdVal();
                                                                                                                                        $("#majorId").change(function(){
                                                                                                                                            changeMajorIdVal();
                                                                                                                                        });
                                                                                                                                        changeMajorIdVal();
                                                                                                                                        $('#classId').next().remove();
                                                                                                                                        $('#classId').searchableSelect();
                                                                                                                                        $('#directId').next().remove();
                                                                                                                                        $('#directId').searchableSelect();
                                                                                                                                        
                                                                                                                                        
                                                                                                                                    })
                                                                                                                                    
                                                                                                                                    
                                                                                                                                    
                                                                                                                                    function changeMajorIdVal(){
                                                                                                                                        var id = $("#majorId").val();
                                                                                                                                        $.ajax({
                                                                                                                                            async:false,
                                                                                                                                            type: 'post',
                                                                                                                                            url: '${pageContext.request.contextPath}/teacher/student_info/getClassInfoListByMajorId',
                                                                                                                                                data:{
                                                                                                                                                    "majorId":id
                                                                                                                                                },
                                                                                                                                                success: function(result) {
                                                                                                                                                    var html='<option value="" >全部</option>';
                                                                                                                                                    for(var i=0;i<result.length;i++){
                                                                                                                                                        html+='<option value='+result[i].id+' >'+result[i].name+'</option>';
                                                                                                                                                    }
                                                                                                                                                    $("#classId").html(html);
                                                                                                                                                    $("#classId").next().remove();
                                                                                                                                                    $("#classId").searchableSelect();
                                                                                                                                                    if('${data.classId}'!=''&&'${data.classId}'!='null'&&'${data.classId}'!=null){
                                                                                                                                                        $("#classId").val('${data.classId}');
                                                                                                                                                        }
                                                                                                                                                    }
                                                                                                                                                });
                                                                                                                                            }
                                                                                                                                            function changeMajorIdVal(){
                                                                                                                                                var id = $("#majorId").val();
                                                                                                                                                $.ajax({
                                                                                                                                                    async:false,
                                                                                                                                                    type: 'post',
                                                                                                                                                    url: '${pageContext.request.contextPath}/teacher/student_info/getMajorDirectInfoListByMajorId',
                                                                                                                                                        data:{
                                                                                                                                                            "majorId":id
                                                                                                                                                        },
                                                                                                                                                        success: function(result) {
                                                                                                                                                            var html='<option value="" >全部</option>';
                                                                                                                                                            for(var i=0;i<result.length;i++){
                                                                                                                                                                html+='<option value='+result[i].id+' >'+result[i].name+'</option>';
                                                                                                                                                            }
                                                                                                                                                            $("#directId").html(html);
                                                                                                                                                            $("#directId").next().remove();
                                                                                                                                                            $("#directId").searchableSelect();
                                                                                                                                                            if('${data.directId}'!=''&&'${data.directId}'!='null'&&'${data.directId}'!=null){
                                                                                                                                                                $("#directId").val('${data.directId}');
                                                                                                                                                                }
                                                                                                                                                            }
                                                                                                                                                        });
                                                                                                                                                    }
                                                                                                                                                    function submitData(){
                                                                                                                                                        var stuNo= $('#stuNo').val();
                                                                                                                                                        var passWord= $('#passWord').val();
                                                                                                                                                        var realName= $('#realName').val();
                                                                                                                                                        var sex= $('#sex').val();
                                                                                                                                                        var celPhone= $('#celPhone').val();
                                                                                                                                                        var majorId= $('#majorId').val();
                                                                                                                                                        var classId= $('#classId').val();
                                                                                                                                                        var directId= $('#directId').val();
                                                                                                                                                        var enterYear= $('#enterYear').val();
                                                                                                                                                        
                                                                                                                                                        if(enterYear!=''){
                                                                                                                                                            if(isIntNum(enterYear)==false){
                                                                                                                                                                alert("入学年份必须填入整数");
                                                                                                                                                                return;
                                                                                                                                                            }
                                                                                                                                                        }
                                                                                                                                                        $.ajax({
                                                                                                                                                            type: 'post',
                                                                                                                                                            url: '${pageContext.request.contextPath}/teacher/student_info/update_submit',
                                                                                                                                                                data:{
                                                                                                                                                                    "id":'${data.id}',
                                                                                                                                                                        "stuNo":stuNo,
                                                                                                                                                                        "passWord":passWord,
                                                                                                                                                                        "realName":realName,
                                                                                                                                                                        "sex":sex,
                                                                                                                                                                        "celPhone":celPhone,
                                                                                                                                                                        "majorId":majorId,
                                                                                                                                                                        "classId":classId,
                                                                                                                                                                        "directId":directId,
                                                                                                                                                                        "enterYear":enterYear
                                                                                                                                                                    },
                                                                                                                                                                    success: function(result) {
                                                                                                                                                                        if(result.code == 0){
                                                                                                                                                                            alert(result.msg);
                                                                                                                                                                            }else{
                                                                                                                                                                                alert(result.msg);
                                                                                                                                                                                self.location=document.referrer;
                                                                                                                                                                            }
                                                                                                                                                                        }
                                                                                                                                                                    });
                                                                                                                                                                }
                                                                                                                                                                
                                                                                                                                                                
                                                                                                                                                                
                                                                                                                                                                </script>
                                                                                                                                                                </body>
                                                                                                                                                                </html>
